package jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @Author Fish Paradise
 * @Description
 * @Date 2019/1/28  19:21
 **/
public class Apple implements InvocationHandler {
    private Object object;

    public Object bind(Object object){
        this.object = object;
        return Proxy.newProxyInstance(object.getClass().getClassLoader(),object.getClass().getInterfaces(),this);
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("这是个苹果");
        Object result = method.invoke(this.object,args);
        System.out.println("after");
        return result;
    }
}
